/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/11/29
*/
#ifndef __EDUI_LUAWINDOW_H__
#define __EDUI_LUAWINDOW_H__

#include "../interface/IWindow.h"
#include "LuaHelper.h"

#ifdef EDUI_USE_LUAPLUS

EDUI_NAMESPACE_BEGIN

class LuaWindow : public LuaClassBase
{
public:
#ifdef EDUI_TEST_NEW_DELETE
    static int m_newdeleteNum;
    static int _GetNewDeleteNum();
#endif
    LuaWindow(IWindow* wnd);
    virtual ~LuaWindow();
    static void* GetInterface(void* data);
    virtual void Release();
    virtual void* GetCObj();
    static void Register(LuaState *L);
public:
    bool SetName(const char* name);
    const char* GetName();
    Uint32 GetID();
    Uint32 GetFlags();
    const char* GetTitle();
    void SetTitle(const char* title);

    int SetIcon(LuaState *L);
    int GetIcon(LuaState *L);

    bool SetCaptionRect(int x, int y, int w, int h);
    int GetCaptionRect(LuaState *L);
    bool SetSizeBox(int l, int t, int r, int b);
    int GetSizeBox(LuaState *L);

    int GetWidth();
    int GetHeight();
    int GetPos(LuaState *L);
    void SetPos(int x, int y);
    int GetSize(LuaState *L);
    void SetSize(int w, int h);
    int GetRect(LuaState *L);
    void SetRect(int x, int y, int w, int h);
    int GetMaxSize(LuaState *L);
    void SetMaxSize(int w, int h);
    int GetMinSize(LuaState *L);
    void SetMinSize(int w, int h);

    bool SetFullScreen(const char* type);

    void MaxWindow();
    void MinWindow();
    void RestoreWindow();
    void ShowWindow();
    void HideWindow();

    bool IsEnabled();
    void SetEnabled(bool enabled);

    void Close(); 
    void AskClose();
    bool IsOK();

    int GetFont(LuaState *L);
    int SetFont(LuaState *L);
    int SetCursor(LuaState *L);
    int GetCursor(LuaState *L);

    //TimerID AddTimer(Uint32 interval, TimerCallback callback, IWindow* wnd);
    //not use data
    int AddTimer(LuaState *L);
    int RemoveTimer(LuaState *L);

    int SetParent(LuaState *L);
    int GetParent(LuaState *L);

    bool SetOpacity(float opacity);
    float GetOpacity();

    int SetFocusCtrl(LuaState *L);
    int GetFocusCtrl(LuaState *L);

    void TabCtrlNext();
    int SetTabCtrl(LuaState *L);
    int GetTabCtrl(LuaState *L);

    void Invaldate();

    int GetRoot(LuaState* L);

    int FindControl(LuaState* L);
    int FindControlByTabID(LuaState *L);

    //void PushMsg(Msg *msg);
    
    bool LoadLayout(const char* xmlfile);
    bool LoadLayoutFromStr(const char* xmlstr);
    int LoadControl(LuaState *L);
    int LoadControlFromStr(LuaState *L);

    int FindTexture(LuaState *L);
    int FindTextureByID(LuaState *L);
    int FindAnimation(LuaState *L);
    int FindAnimationByID(LuaState *L);
protected:
    IWindow* m_cobj;
};

EDUI_NAMESPACE_END

#endif
#endif